﻿-- =========================================================================================================
-- Author:		MICHAEL RITACCO
-- Copyright:	2010 MEKHANO GROUP LLC
-- Version:		10/03/2010 1.0
-- =========================================================================================================
CREATE PROCEDURE [flcr].[api_resource_sel_lov]
@RESOURCE_ID INT
,@ACTIVE_FLG BIT = NULL
,@RESOURCE_TYPE INT = NULL
,@SUPPLIER_ID INT = NULL
,@SUPPORT_ROLE_ID INT = NULL
,@DOMAIN_ID INT = NULL

AS
BEGIN TRY
  
	SELECT	A.[RESOURCE_ID]
			,A.[RESOURCE_NAME]
			,A.[PARENT_ID] 
			,A.[SORT_ORDER]
			,A.[RESOURCE_TYPE] 
			,B.[RESOURCE_TYPE_NAME]
	  FROM	[FLCR].[RESOURCE] A
	 INNER JOIN [FLCR].[RESOURCE_TYPE] B 
	    ON	A.[RESOURCE_TYPE] = B.[RESOURCE_TYPE] 
     WHERE	A.[RESOURCE_ID] = COALESCE(@RESOURCE_ID,A.[RESOURCE_ID])
	   AND	A.[ACTIVE_FLG] = COALESCE(@ACTIVE_FLG,A.[ACTIVE_FLG])
	   AND	A.[RESOURCE_TYPE] = COALESCE(@RESOURCE_TYPE,A.[RESOURCE_TYPE])
	   AND	A.[SUPPLIER_ID] = COALESCE(@SUPPLIER_ID,A.[SUPPLIER_ID])
	   AND	A.[SUPPORT_ROLE_ID] = COALESCE(@SUPPORT_ROLE_ID,A.[SUPPORT_ROLE_ID])
	   AND	A.[DOMAIN_ID]  = COALESCE(@DOMAIN_ID,A.[DOMAIN_ID])

END TRY
BEGIN CATCH
	EXEC [flcr].[utl_getDBError];
END CATCH
